package com.yn.pet.controller.pc.response;

import com.yn.pet.bus.entity.DeviceSyncSettings;
import com.yn.pet.enums.AlarmSwitchEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public class AlarmListResponse {

    //id
    @ApiModelProperty("设备同步id")
    private Long id;


    //围栏报警(bit 8)
    @ApiModelProperty("围栏报警")
    private Integer fenceEnabled;

    @ApiModelProperty("围栏报警字符串")
    private String fenceEnabledStr;

    //离线报警(bit 7)
    @ApiModelProperty("离线报警")
    private Integer offlineEnabled;

    @ApiModelProperty("离线报警字符串")
    private String offlineEnabledStr;

    //低电量报警(bit 6)
    @ApiModelProperty("低电量报警")
    private Integer lowBatteryEnabled;

    @ApiModelProperty("低电量报警字符串")
    private String lowBatteryEnabledStr;

    //震动报警 (bit 2)
    @ApiModelProperty("震动报警")
    private Integer vibrationEnabled;

    @ApiModelProperty("震动报警字符串")
    private String vibrationEnabledStr;


    public static AlarmListResponse transform(DeviceSyncSettings deviceSyncSettings) {
        AlarmListResponse response = new AlarmListResponse();
        response.setId(deviceSyncSettings.getId());

        response.setFenceEnabled(deviceSyncSettings.getFenceEnabled());
        response.setFenceEnabledStr(AlarmSwitchEnum.getByCode(deviceSyncSettings.getFenceEnabled()).getName());

        response.setOfflineEnabled(deviceSyncSettings.getOfflineEnabled());
        response.setOfflineEnabledStr(AlarmSwitchEnum.getByCode(deviceSyncSettings.getOfflineEnabled()).getName());

        response.setLowBatteryEnabled(deviceSyncSettings.getLowBatteryEnabled());
        response.setLowBatteryEnabledStr(AlarmSwitchEnum.getByCode(deviceSyncSettings.getLowBatteryEnabled()).getName());

        response.setVibrationEnabled(deviceSyncSettings.getVibrationEnabled());
        response.setVibrationEnabledStr(AlarmSwitchEnum.getByCode(deviceSyncSettings.getVibrationEnabled()).getName());
        return response;
    }

}
